Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify and correct ProbabilitySampler behaviour #111

Conversation

fbogsany
Copy link
Contributor

This simplifies the interface and implementation of the ProbabilitySampler, as well as fixing some bugs wrt the OTEP: https://github.com/open-telemetry/oteps/blob/master/text/0006-sampling.md

I'll call out specifics in comments.

apply_to_root_spans: true,
apply_to_remote_parent: true,
apply_to_all_spans: false)
apply_probability_to: :root_spans_and_remote_parent)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The collection of boolean flags was confusing, interdependent, incorrectly implemented, and didn't capture either the spirit or intent of the OTEP. Since we're in Ruby, we can have Symbols, so this uses a single Symbol argument to distinguish the 3 supported cases.

@@ -26,51 +30,48 @@ def initialize(probability, hints:, ignore_parent:, apply_to_root_spans:, apply_
#
# Callable interface for probability sampler. See {Samplers}.
def call(trace_id:, span_id:, parent_context:, hint:, links:, name:, kind:, attributes:)
take_hint(hint) ||
use_parent_sampling(parent_context) ||
use_link_sampling(links) ||
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OTEP talks about links, but the decision table for ProbabilitySampler doesn't use them.

use_probability_sampling(trace_id) ||
NOT_RECORD
end
ignore(links, name, kind, attributes)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to explicitly ignore the parameters the ProbabilitySampler doesn't use in its decision. It seemed cleaner that just encoding it in a comment.

NOT_RECORD if !@apply_to_root_spans && parent_context.nil?
def sample(hint, trace_id, parent_context)
if parent_context.nil?
hint == HINT_RECORD_AND_PROPAGATE || probably(trace_id)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oteps 2019-09-30 19-47-09

if parent_context.nil?
hint == HINT_RECORD_AND_PROPAGATE || probably(trace_id)
else
parent_sampled_flag(parent_context) || hint == HINT_RECORD_AND_PROPAGATE || probably_for_child(parent_context, trace_id)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oteps 2019-09-30 19-48-18

@@ -60,12 +60,6 @@
result.wont_be :sampled?
end

it 'respects link sampling' do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProbabilitySampler doesn't respect Link sampling.

@@ -83,35 +77,30 @@
result.wont_be :sampled?
end

it 'does not sample a root span unless apply_to_root_spans' do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a supported case for ProbabilitySampler. The probability applies to "root spans", "root spans and remote parent", or "all spans".

@fbogsany
Copy link
Contributor Author

fbogsany commented Oct 2, 2019

This is ready for another 👀

@fbogsany fbogsany merged commit 8c9f417 into open-telemetry:master Oct 3, 2019
@fbogsany fbogsany deleted the simplify-and-correctify-probability-sampler branch October 3, 2019 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants